import 'package:factoryside/bean/addr_entity.dart';

addrEntityFromJson(AddrEntity data, Map<String, dynamic> json) {
	if (json['StatusCode'] != null) {
		data.statusCode = json['StatusCode'] is String
				? int.tryParse(json['StatusCode'])
				: json['StatusCode'].toInt();
	}
	if (json['Info'] != null) {
		data.info = json['Info'].toString();
	}
	if (json['Count'] != null) {
		data.count = json['Count'] is String
				? int.tryParse(json['Count'])
				: json['Count'].toInt();
	}
	if (json['Data'] != null) {
		data.data = new List<AddrData>();
		(json['Data'] as List).forEach((v) {
			data.data.add(new AddrData().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> addrEntityToJson(AddrEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['StatusCode'] = entity.statusCode;
	data['Info'] = entity.info;
	data['Count'] = entity.count;
	if (entity.data != null) {
		data['Data'] =  entity.data.map((v) => v.toJson()).toList();
	}
	return data;
}

addrDataFromJson(AddrData data, Map<String, dynamic> json) {
	if (json['Id'] != null) {
		data.id = json['Id'] is String
				? int.tryParse(json['Id'])
				: json['Id'].toInt();
	}
	if (json['AccountAdressID'] != null) {
		data.accountAdressID = json['AccountAdressID'] is String
				? int.tryParse(json['AccountAdressID'])
				: json['AccountAdressID'].toInt();
	}
	if (json['UserID'] != null) {
		data.userID = json['UserID'].toString();
	}
	if (json['Province'] != null) {
		data.province = json['Province'].toString();
	}
	if (json['ProvinceCode'] != null) {
		data.provinceCode = json['ProvinceCode'] is String
				? int.tryParse(json['ProvinceCode'])
				: json['ProvinceCode'].toInt();
	}
	if (json['AddressProvinceName'] != null) {
		data.addressProvinceName = json['AddressProvinceName'];
	}
	if (json['City'] != null) {
		data.city = json['City'].toString();
	}
	if (json['CityCode'] != null) {
		data.cityCode = json['CityCode'] is String
				? int.tryParse(json['CityCode'])
				: json['CityCode'].toInt();
	}
	if (json['AddressCityName'] != null) {
		data.addressCityName = json['AddressCityName'];
	}
	if (json['Area'] != null) {
		data.area = json['Area'].toString();
	}
	if (json['AreaCode'] != null) {
		data.areaCode = json['AreaCode'] is String
				? int.tryParse(json['AreaCode'])
				: json['AreaCode'].toInt();
	}
	if (json['AddressAreaName'] != null) {
		data.addressAreaName = json['AddressAreaName'];
	}
	if (json['District'] != null) {
		data.district = json['District'].toString();
	}
	if (json['DistrictCode'] != null) {
		data.districtCode = json['DistrictCode'] is String
				? int.tryParse(json['DistrictCode'])
				: json['DistrictCode'].toInt();
	}
	if (json['AddressDistrictName'] != null) {
		data.addressDistrictName = json['AddressDistrictName'];
	}
	if (json['Address'] != null) {
		data.address = json['Address'].toString();
	}
	if (json['EasyAddress'] != null) {
		data.easyAddress = json['EasyAddress'];
	}
	if (json['IsDefault'] != null) {
		data.isDefault = json['IsDefault'].toString();
	}
	if (json['IsUse'] != null) {
		data.isUse = json['IsUse'].toString();
	}
	if (json['UserName'] != null) {
		data.userName = json['UserName'].toString();
	}
	if (json['Phone'] != null) {
		data.phone = json['Phone'].toString();
	}
	if (json['Mobile'] != null) {
		data.mobile = json['Mobile'];
	}
	if (json['Sex'] != null) {
		data.sex = json['Sex'];
	}
	if (json['Mph'] != null) {
		data.mph = json['Mph'];
	}
	if (json['Longitude'] != null) {
		data.longitude = json['Longitude'];
	}
	if (json['Dimension'] != null) {
		data.dimension = json['Dimension'];
	}
	if (json['Version'] != null) {
		data.version = json['Version'] is String
				? int.tryParse(json['Version'])
				: json['Version'].toInt();
	}
	return data;
}

Map<String, dynamic> addrDataToJson(AddrData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['Id'] = entity.id;
	data['AccountAdressID'] = entity.accountAdressID;
	data['UserID'] = entity.userID;
	data['Province'] = entity.province;
	data['ProvinceCode'] = entity.provinceCode;
	data['AddressProvinceName'] = entity.addressProvinceName;
	data['City'] = entity.city;
	data['CityCode'] = entity.cityCode;
	data['AddressCityName'] = entity.addressCityName;
	data['Area'] = entity.area;
	data['AreaCode'] = entity.areaCode;
	data['AddressAreaName'] = entity.addressAreaName;
	data['District'] = entity.district;
	data['DistrictCode'] = entity.districtCode;
	data['AddressDistrictName'] = entity.addressDistrictName;
	data['Address'] = entity.address;
	data['EasyAddress'] = entity.easyAddress;
	data['IsDefault'] = entity.isDefault;
	data['IsUse'] = entity.isUse;
	data['UserName'] = entity.userName;
	data['Phone'] = entity.phone;
	data['Mobile'] = entity.mobile;
	data['Sex'] = entity.sex;
	data['Mph'] = entity.mph;
	data['Longitude'] = entity.longitude;
	data['Dimension'] = entity.dimension;
	data['Version'] = entity.version;
	return data;
}